from typing import Union

from fastapi import FastAPI, Cookie, Header

app = FastAPI()


@app.get("/")
def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}

@app.get("/items_cookie")
async def items_cookie(items_cookie: Union[str, None] = Cookie(default=None)):
    return {"items_cookie": items_cookie}

@app.get("/items_header")
async def items_header(items_header: Union[str, None] = Header(default=None)):
    return {"items_header": items_header}